Using Logic
About “Using Logic”
“Logic” refers to the condition a respondent must meet in order to see a question, receive an email, or trigger some other behavior in a Qualtrics survey. Each of the following features in Qualtrics uses logic in some way:
- Branch logic for showing a block of questions conditionally.
- Display logic for showing a single question conditionally.
- Quotas for determining which respondents should count toward a response limit you set.
- Custom validation for requiring respondents to meet certain answer requirements before proceeding in a survey.
Creating Conditions
Whenever you are presented with a logic window in Qualtrics (such display logic or branch logic), you will see a series of dropdown menus. These menus determine the condition parameters. Each menu specifies the logic condition further until you have a full statement.
In the example above, we are trying to hide a question about student mentors from anyone who isn’t a freshman. If we read this screenshot word for word, it says,
Basically, a respondent has to confirm that they’re a freshman before we ask them who their student mentor is.
Creating a Basic Condition
It’s best to think of your condition as a statement. Think of the condition you want the respondent to meet, and build a statement that describes that condition.
Let’s start with an example. We want students to rate their dorms. However, we don’t want to ask this question if the student says they don’t live in student housing.
Qtip: Based on the type of field you choose in Step 1, the following steps may vary. The purpose of these instructions is to get you started with a general example.
- Decide what your logic will be based on. Is it the answer to a question? Embedded data set in the survey flow? Contact list information? In our example (and in most instances), this dropdown should say Question.
- Select the field (or question) the logic should be based on. Here, we choose, Do you live in student housing?
- These dropdowns finish the sentence. Here, it says No Is Not Selected. We could have also put Yes Is Selected. Basically, this is a person who has confirmed they live in student housing.
Adding Multiple Conditions
Sometimes the logic you want to create requires more complex conditions. Conditions can be connected with an AND conjunction or with an OR conjunction.
When conditions are linked by AND, that means both conditions must be met. If conditions are linked by OR, that means either condition can be met. Note that as you add more logic, conditions linked by AND are evaluated first, followed by conditions linked by OR.
Example: This question will display if the respondent is a freshman AND the respondent lives in student housing. If the respondent is a freshman but does not live in student housing, they will not see this question, and vice versa.
how to add a new condition
- Click the plus sign ( + ) to the right of an existing condition.
- Select whether your new statement should be an And statement or an Or statement.
Troubleshooting multiple conditions
Depending on your needs, conditions may get longer and more complex than the examples we’ve tried out so far.
What respondents do you think will meet the following quota? Remember the order of operations: conditions linked by AND are evaluated first, followed by conditions linked by OR.
These are the 3 different segments of respondents that would fulfill this quota:
- Never Married and Female (regardless of age), OR
- Over 18 years old and Widowed (regardless of gender), OR
- Married (regardless of age or gender)
When you add this many conditions to your logic, we recommend using new logic sets to separate everything more clearly. Read the next section to learn more.
Creating Advanced Conditions with Logic Sets
As your logic becomes more advanced and includes more conditions, you may need to start using logic sets. A logic set is a group of conditions that are evaluated together. Similar to statements, logic sets can be linked with an AND conjunction or with an OR conjunction.
Logic sets allow you to say that if a whole group of statements is true AND/OR if another whole group of statements is true, then the condition is met.
In this example, the question will only be displayed if the respondent is either:
- 18–24 years old AND from the US
- OR 25–34 years old AND from Canada.
The question will not be displayed if the respondent is 18-24 from Canada, or 25-34 from the US. It also won’t be displayed to 18-24 year olds from any other country, and so on.
how to add a new logic set
- Click the plus sign ( + ).
- In front of your new statement, open the And dropdown.
- Select Move to a new Logic Set.
- Set the condition(s) for your new logic set.
- Determine if your logic sets are joined by And or by Or.
Types of Logic
Now that you understand how to build logic in Qualtrics, we can dive into the specific types of logic available. Let’s start by going into what’s available for each part of the platform that uses logic and how each type works.
Logic can be based off of how a respondent answers a question, information saved ahead of time in a contact list, whether or not a quota has been met, and more. However, based on where you’re using logic in the platform, not all of these options will make sense. The table below illustrates the types of logic you can use in each part of Qualtrics.
Logic Based on… | Branch Logic | Display Logic | Quotas | Custom Validation | Email Triggers | Contact List Triggers |
Questions | Yes | Yes | Yes | Yes | Yes | Yes |
Embedded Data | Yes | Yes | Yes | No | Yes | Yes |
Contact Lists | No | Yes | No | No | No | No |
Quotas | Yes | Yes | Yes | No | Yes | Yes |
GeoIP Location | Yes | Yes | No | No | No | No |
Loop & Merge | No | Yes | No | No | No | No |
Device Type | Yes | Yes | No | No | No | No |
Logic Based on a Question
You can set logic based on answers respondents give to questions. Depending on the type of question, you’ll encounter different logic options. There are 2 main types of logic options you’ll see: choice selection and text entry.
Choice selection questions are any questions where the respondent selects from a range of predetermined options (e.g., multiple choice, matrix, slider). Open-ended questions are any questions where the respondent inputs a free-form answer (text entry, constant sum, rank order).
setting logic based on choice selection questions
- Choose Question from the first dropdown.
- Choose the specific question from the 2nd dropdown.
- Choose the specific answer choice from the 3rd dropdown.
- Choose how the respondent should interact with the choice from the 4th dropdown.
- Click Save.
Only respondents who have indicated that they are freshmen will see this question.
setting logic based on open ended questions
- Choose Question from the first dropdown.
- Choose the specific question.
- If your text entry is a form, then choose the specific field. If your text entry question isn’t a form, you may not have this step.
- Enter a value to use for your logic.
- Select Ignore Case if you don’t want capitalization to affect the logic.
- Decide how the value the respondent enters should compare to the value you specified.
- Click Save.
A question with this logic will only display to respondents who have “@qualtrics.com” as part of their email address.
Possible Fields for Question Logic
You’ll notice that there are many ways to format logic based on a question. This section runs through the different fields, what they mean, and how you fill them out.
Standard
These options tend to show up on all question types.
- Is / Is Not Displayed: Base logic on the choices displayed to the respondent. See our page on adding display logic to answer choices for more information on hiding and displaying choices to respondents.
Multiple Choice
Any question with a multiple choice option can have logic based on these fields. This not only includes multiple choice, but side by sides, matrix tables, and so on.
- Is / Is Not Selected: Base logic on specific choices the respondent did or did not select.
- Selected Count: This option only appears for multiple choice questions set to allow multiple answers. This option will allow you to base logic on how many answers someone selected for a multiple choice question, rather than the exact answers they selected.
- Choice (Text Entry): This field is only an option when you allow text entry on a choice. (For example, adding an “Other” option with a fill-in-the-blank next to it.) Selecting this field allows you to base logic on the text that has been entered in this choice.
Text Entry and Numeric Questions
Any open-ended or numeric question has these options. This includes text entry questions, other text, text entry matrix tables, sliders, constant sums, and so on.
- Is / Is Not Equal To: Base logic on an exact number the answer is or is not equal to. For text entry, this can be used as an exact match, requiring the response to contain an exact phrase or word.
- Is Greater / Less Than / Equal To: Base logic on answers greater than, less than, or equal to a specific number.
- Is / Is Not Empty: Base logic on whether or not the respondent left the question blank.
- Contains / Does Not Contain: Base logic on whether certain content is in the response. Selecting Ignore Case means the question will ignore capitalization.
- Matches Regex: Base logic on regex code. Regex code can be useful for restricting exact characters, words, and more.
Qtip: Because Regex is custom coding, Qualtrics Support cannot help you create your regex. They can only help you figure out where it goes once it’s done. You can always try asking our community of dedicated users instead.
Matrix Tables
These fields apply to matrix tables and side by sides.
- Scale Point: Choose whether a specific scale point has been selected or displayed.
- Statement – Scale Point: Choose whether a specific scale point has been selected for a specific statement.
- Scale Point (Count): Base logic on the number of times a scale point has been selected.
- Statement (Recode): Instead of choosing a specific scale point for a statement, you can instead use the recoded numeric values of your scale to set a range.
Questions in Looped Blocks
When you apply loop & merge to a block, the questions in that looped block get additional fields, in addition to the standard and multiple choice ones:
- Select a Loop by Name: A specific choice is selected in a specific loop.
- Current Loop: A specific choice must be selected on the current loop.
Example: You are asking people to review events they attended. The block loops for every event they say they attended. In Q25 they are asked, “Did you enjoy your time?” And then, if they say “Yes,” Text Entry question Q26, “Please elaborate,” appears.
Maybe the respondent enjoyed the first event they will review, but not the second. In that case, you need to use “Current Loop” display logic to ensure only selecting “Yes” on the current loop makes the next question appear.
- Any Loop: A specific choice was selected on any loop.
Example: You’re running a survey about several events you hosted. In a looped block, you ask respondents if they got sick off the food. It doesn’t matter if the respondent only got sick at 1 out of 100 events – you want to know what they ate that made them sick. In a later block, you put in a follow-up question that shows up if they said they got sick in Any Loop.
- All Loops: A specific choice must be selected on all loops.
Logic Based on Embedded Data
Embedded data fields connect additional information to each response, such as an ID number or a supervisor name.
setting logic based on Embedded Data
- Choose Embedded Data from the first dropdown.
- In the next field, click the dropdown arrow to see a list of the embedded data saved in your survey flow.
- Click the name of the embedded data field you would like to use in your logic.
- Select an embedded data value from the dropdown, or type in a value. Make sure to get spelling and capitalization exactly the same as it appears in your survey flow or contact list.
- Choose how the respondent’s embedded data value should compare to the value you specified.
Qtip: If you’re going to type an exact value (for example, a Professor’s name, or a valid zip code), you should use Is Equal To or Contains.
- Click Save.
Using Piped Text with Embedded Data Logic
Have you ever wanted to ensure 2 embedded data fields don’t have the same value? Or make sure that the answer provided in a question matches the one provided in an embedded data field? You can do all of this and more with piped text!
Piped text allows you to take the value from any embedded data, question, quota, score, and so on that the respondent has data for. Since the final field in embedded data logic is blank, you can paste piped text here.
If you are using display logic, there will be a dropdown arrow to select the piped text. If you are using branch logic, you will have to create the piped text in a survey question or embedded data element, cut it, and paste it into the field.
Example: You want to send respondents to a special block if the professor you have saved for them in your contact list doesn’t match the professor they say they have. When setting up the branch logic, you pipe the Selected Choices for the question of what professor they have in the last field of the branch logic. See the following image.
Logic Based on a Contact List
If you’re planning to distribute your survey using a contact list, information from that list (such as name and email address) can be used in logic conditions.
setting logic based on a contact list
- Choose Contact List.
- Choose the desired contact list field (e.g., First Name or Email).
- Enter the value to be used for your logic.
- Choose how the respondent’s contact list value should compare to the value you specified.
- Click Save.
A question with this logic will only display to those respondents with a qualtrics.com email address.
Possible Fields for Contact List Logic
To learn more about each contact field, see the linked support page.
- First Name: Base logic on the contact’s first name.
- Last Name: Base logic on the contact’s last name.
- Email: Base logic on the contact’s email address.
- External Data: Base logic on the contact’s External Data Reference.
Logic Based on a Quota
Quotas allow you to keep track of how many respondents in certain groups have completed your survey. Logic conditions can be based on whether or not a specific Quota has been met, as well as what the value of the Quota currently is.
setting logic based on a Quota
- Choose Quota from the 1st dropdown.
- Choose which quota you want to base your logic on.
- Choose whether to act if the quota Has been met or Has not been met or choose to enter a numeric value.
- Click Save.
A question with this logic will display until the Qualtrics Users quota has been met.
Possible Fields for Quota Logic
- Has Not / Been Met: Base logic on whether a quota has been met or not.
- Is / Is Not Equal To: A quota’s “count” is the number of respondents who have taken the survey and met the conditions of the quota. You can base logic on an exact count the quota is or is not equal to.
- Is Greater / Less Than / Equal To: Base logic on what the number of people who have met the quota are greater than, less than, or equal to.
Logic Based on GeoIP Location
Qualtrics can use the respondent’s IP address to estimate their location. This information can be used in your survey logic. This type of logic can only be applied to branch and display logic.
setting logic based on GeoIP Location
- Choose GeoIP Location from the 1st dropdown.
- Choose the location category.
- Enter the location identifier value to be used for your logic.
- Choose how the respondent’s location identifier value should compare to the value you specified.
- Click Save.
A question with this logic will only be shown to respondents in the 84508 postal code.
Possible Fields for GeoIP Location Logic
GeoIP Location allows you to choose a location category and then define it.
Location Category
- Postal Code
- City
- State/Region (Make sure to use State Codes, e.g., WA, not Washington.)
- Country Name
- Country Code
- Location From Map
Defining Fields
You define the first 5 location type by using text entry-style fields.
- Is / Is Not Equal To: Base logic on an exact location name or value.
- Is Greater / Less Than / Equal To: Base location on numbers greater than, less than, or equal to a specific number.
- Contains / Does Not Contain: The location contains certain letters/words/phrases.
- Matches Regex: Base logic on regex code. All regex code must be contained inside forward slashes ( / ). For example, /regex/.
Qtip: Because Regex is custom coding, Qualtrics Support cannot help you create your regex. They can only help you figure out where it goes once it’s done.
Location from Map
Location From Map allows you to select locations from a provided map.
- Click Select Locations.
- Select an island or continent.
- Select a country.
- Select cities, states, or regions. Note that not every city will be available.
- Click Save when you’re done.
If you selected the wrong country or continent, you can click Back to world view.
If you selected lots of locations you no longer want to select, you can get rid of them all by clicking Clear.
Logic Based on Loop & Merge
Within a block that has loop & merge applied, you can apply logic based on what loop the respondent is currently in. This kind of logic can only be applied as display logic.
- Not / Current Loop: Choose a specific loop and whether it is the current loop or not.
Logic Based on Device Type
You can base conditions on the type of mobile device that is or is not being used. This includes Mobile (any mobile device), Blackberry, Android, iPhone, iPod, Opera Mobile, Palm, Windows Mobile, and Other Mobile (any mobile device that is not listed here).
Example: In our survey, we have special questions for people who are accessing the survey on mobile, and special questions for people who are accessing the survey on desktop. For mobile users, the logic says to show the mobile questions if Device Type Is Mobile. For desktop users, the logic says to show the desktop questions if Device Type Is Not Mobile.
Logic Based on True – False
For both display logic and branch logic, you can create a logic condition that is either always true or always false. This can be especially helpful when you’re still building your survey, as you can test the different paths your survey takers could follow without you needing to build complex logic conditions. Additionally, using the false condition is particularly useful for hiding questions in an active survey since this allows you to create a condition that always evaluates to false.
Setting Logic Based on True – False
- Choose True – False from the first dropdown menu.
- Select whether you want the condition to always evaluate as True or False.
- Click Save.
If you select True, then the question will always be displayed to respondents. If you select False, then the question will never be displayed to respondents.